<?php defined('IN_IA') or exit('Access Denied');?>

<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>
<div class='container' style='padding:0 5px 10px;margin:0;width:100%'>

<ul class="nav nav-tabs">
  <li <?php  if($op == 'post') { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('event_manage', array('op' => 'post'));?>">添加数据</a></li>
  <li <?php  if($op == 'display') { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('event_manage',array('op'=>'display'));?>">管理数据</a></li>
 
</ul>
<?php  if($op =='display') { ?>
<div class="panel panel-success">
  <div class="panel-heading">常用工具 > 数据列表</div>
  
</div>

	<form id="form2" class="form-horizontal" method="post">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
				<th style="width:40px;">全选</th>
					<th style="width:50px;">事件ID</th>			
          			<th style="width:90px;">标题</th>
          			<th style="width:180px;">内容</th>
          			<th style="width:60px;">时间</th>
          			<th style="width:40px;">强调</th>
					<th style="min-width:60px;width:60px;">删除</th>
				</tr>
			</thead>
			<tbody>
				<?php  if(is_array($list)) { foreach($list as $item) { ?>
				<td><input type="checkbox" value="<?php  echo $item['event_id'];?>" name="delete[]"></td>
					<td><?php  echo $item['event_id'];?></td>
					<td><?php  echo $item['event_title'];?></td>
					<td><?php  echo $item['event_content'];?></td>
					<td><?php  echo $item['event_time'];?></td>
					<td><?php  if($item['highlight'] == "1"){echo "True";}else{echo "False";}?></td>
					<td>
					<a href="<?php  echo $this->createWebUrl('event_manage', array('op' => 'post', 'event_id' => $item['event_id']))?>" title="编辑" class="btn btn-xs btn-primary"><span class="icon icon-compose">编辑</span></a>
					
					<a onclick="if(confirm('此操作不可恢复，确认吗？')){location.href='<?php  echo $this->createWebUrl('event_manage', array('event_id' => $item['event_id'],'op'=>'del'))?>'}" href="javascript:;" title="删除" class="btn btn-xs btn-danger"><span class="icon icon-close">删除</span></a>
					</td>				
				</tr>
				
				<?php  } } ?>
				<tr >
				<td><input type="checkbox"  onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});" name=''>    <input class="btn btn-primary btn-xs" type="submit" value="删除" name="submit" ></td><td></td><td></td><td></td>
				</tr>
			</tbody>
		</table>
		<input type="hidden" value="event_manage" name="do">
		<input type="hidden" value="del" name="op">
		<input type="hidden" name="token" value="<?php  echo $_W['token'];?>" />
		
	</form>
	<?php  echo $pager;?>
	
	

	<script>
		$(function(){
			$('.pagination').removeClass().children().addClass('pagination');

		})
	</script>
	<script>
		$('#form2').submit(function(){
			if($(":checkbox[name='delete[]']:checked").size() > 0){
				return confirm('删除后不可恢复，您确定删除吗？');
			}
			return false;
		}); 
	</script>	
	</div>
		<?php  } else if($op == 'post') { ?>
<div class="panel panel-success">
  <div class="panel-heading">常用工具 > 微事件 > 添加/修改数据</div>
  
</div>

<div class="main">
	<form action="" method="post" class="form-horizontal form">
	<div class="panel panel-default">
		
		<div class="panel-body">
		
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">标题</label>
				<div class="col-sm-8">
					<input type="text" name="event_title" class="form-control" value="<?php  echo $item['event_title'];?>" />
					<span class="help-block"></span>
				</div>
			</div>	
				
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">内容</label>
				<div class="col-sm-8">
					<textarea id="remark" name="event_content" class="form-control">
					<?php  echo $item['event_content'];?> 
					</textarea>
					<span class="help-block"></span>
				</div>
			</div>

			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">时间</label>
				<div class="col-sm-8">
					<input type="date" name="event_time" class="form-control" value="<?php  echo $item['event_time'];?>" /> 
					<span class="help-block"></span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">强调</label>
				<div class="col-sm-8">
					<input name="highlight" type="radio" value="1" <?php  if($item['highlight']=="1"){?>checked="checked"<?php  }?>/>TRUE&nbsp;&nbsp;&nbsp;&nbsp;
					<input name="highlight" type="radio" value="0" <?php  if($item['highlight']=="0"){?>checked="checked"<?php  }?>/> FALSE
					<span class="help-block"></span>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
				<div class="col-sm-4">
				<input type="hidden" name="event_id" value="<?php  echo $item['event_id'];?>">
				<input type="hidden" name="token" value="<?php  echo $_W['token'];?>" />
					<input name="submit" type="submit" value="提交" class="btn btn-primary span3" />
					
				</div>
			</div>
			
			</div>
			</div>
	</form>
</div>
	
<?php  } ?>		
</div>
<script>
require(['jquery','util'], function($, util){
	$(function(){
		var editor = util.editor($('#remark')[0]);
 
	});
});
</script>
<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/footer', TEMPLATE_INCLUDEPATH)) : (include template('common/footer', TEMPLATE_INCLUDEPATH));?>
